import Vue from 'vue'

import Router from 'vue-router'

Vue.use(Router)
var router = new Router({
    routes:[
        {path:'/',redirect:'/hh'},
        {path:'/hh',name:'hh',component:()=>import('../components/HelloWorld.vue'), children:[

            {path:'/users',name:'users',component:()=>import('../components/1.vue')},
            {path:'/reports',name:'reports',component:()=>import('../components/tubiao.vue')},
            {path:'/roles',name:'roles',component:()=>import('../components/2.vue')},
            {path:'/rights',name:'rights',component:()=>import('../components/3.vue')},
            {path:'/goods',name:'goods',component:()=>import('../components/commodity/list.vue')},
            {path:'/orders',name:'orders',component:()=>import('../components/oreder/oreder.vue')},
            {path:'/categories',name:'categories',component:()=>import('../components/commodity/categories.vue')},
            {path:'/params',name:'params',component:()=>import('../components/commodity/params.vue')},
            {path:'/add',name:'add',component:()=>import('../components/commodity/add.vue')},

        ]},



        {path:'/dl',name:'dl',component:()=>import('../components/dl.vue')},
        
    ]
})


// 路由导航守卫
router.beforeEach((to,form,next)=>{

    if(to.path==='/dl'){
       
        next()
    }else{
        if(localStorage.getItem('todo')){
            next()
        }else{
            next('/dl')
        }
    }
      
        

})

export default router
